package cn.hnu.qq.global;

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;

import cn.hnu.qq.entity.message.Message;

public class JsonOutputStream extends BufferedOutputStream {

	private ObjectOutputStream output;
	
	public JsonOutputStream(OutputStream out) {
		super(out);
		try {
			output = new ObjectOutputStream(this);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void writeObject(Object mes) throws IOException {
//		byte[] data =  JSON.toJSONBytes(mes, SerializerFeature.WriteClassName);
//		super.write(data);
//		super.flush();
		
		output.writeObject(mes);
		output.flush();
	}

	
}
